document.write("<script language=javascript src='/plugs/encrypt/jsencrypt.js'></script>");

// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwxtIfHfJ9s3ZhizAnlwj/2+0WKzwOfloen7iihNSEi+v11s7gI+3X30ksZ0ljkI5aMrXDVxA7DfGKnoXkiGCaS0Te2i/P62zUrAJHPo9n9DL9sEmxuDwFxOuxT1/QijkYTkkpPbCX7Uae676kafXCehWCiBuv0Wh1T4Wb2zGWMwIDAQAB';

/**
 *  加密;做了转换，后台也要转换password = password.replaceAll("%2B","+");
 * @param txt
 * @returns {string}
 * @constructor
 */
const RSA_ENCRYPT = function encrypt(txt) {
  const encryptor = new JSEncrypt();
  encryptor.setPublicKey(publicKey); // 设置公钥
  let encry = encryptor.encrypt(txt); // 对需要加密的数据进行加密
  return encodeURI(encry).replace(/\+/g, '%2B');
};

// 解密
/*export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}*/

